Fast Ignore
A fast parser and processor for .gitignore
files.
Note: terminal slashes on globs are ignored for now.
Install
npm install --save fast-ignore
Usage
import fastIgnore from 'fast-ignore';
const gitignore = `
# Some always-ignore files
*~
*.err
*.log
._*
.cache
.fseventsd
.DocumentRevisions*
.DS_Store
.TemporaryItems
.Trashes
Thumbs.db
# Some project-specific ignores
dist
node_modules
`;
const ignore = fastIgnore ( gitignore );
ignore ( 'foo/bar.js' );
ignore ( 'node_modules/foo/bar.js' );
ignore ( 'dist/foo/bar.js' );
const prettierignore = `
**/test
**/__test__
# The following globs are effectively useless
# because they can't un-ignore something that was ignored by any previous ignore files
!dist
!node_modules
`;
const comboIgnore = fastIgnore ([ gitignore, prettierignore ]);
comboIgnore ( 'foo/bar.js' );
comboIgnore ( 'node_modules/foo/bar.js' );
comboIgnore ( 'dist/foo/bar.js' );
comboIgnore ( 'test/foo/bar.js' );
License
MIT © Fabio Spampinato